<?php 

/**
 * 装柜信息管理
 * @copyright   Copyright (c) 2006 - 2010 DZH 友拓软件友拓通
 * @category   	装柜信息
 * @package  	Action
 * @author    	黄明兴
 * @version 	2.1,2012-07-22
*/

class LoadContainerPublicAction extends RelationCommonAction {
	
	/// 发送EMAIL的字段名称
	public $_email_object_id 		=	'factory_id';
	
	/// 暂存庥装箱列表
	public function alistUndelivery(){
		$this->_autoIndex('index');
	}
	
	/// 待装柜列表
	public function waitLoadContainer(){
		$this->list = D('LoadContainer')->waitLoadContainer();
		if ($_POST['search_form']) {
			$this->display ('waitlist');
		}else {
			$this->display('waitDelivery');
		}
	}
	
	/// 计算厂家小计
	public function _after_edit(){ 
		$this->factory_list  = D('LoadContainer')->getFactoryDetail($this->rs['detail']);
		$temp_file	=	empty($this->_Member)?ACTION_NAME:$this->_Member.ACTION_NAME;  
		$this->display($temp_file);
	}
	
	/// 计算厂家小计
	public function _after_view(){ 
		$this->factory_list  = D('LoadContainer')->getFactoryDetail($this->rs['detail']);
		$temp_file	=	empty($this->_Member)?ACTION_NAME:$this->_Member.ACTION_NAME;  
		$this->display($temp_file);
	}
	
	/**
	 * email发送的对象 例如销售单给客户 入库单发送给多个厂家
	 *
	 * @param  array $info
	 * @return array
	 */
	public function flowEmailInfo($info){
		if ($info['id']>0){
			$id=	$info['id'];
			$model	= M('load_container_details');
	 		$info	= $model
	 			->field('d.factory_id as factory_id')
				->join('as a 
						left join load_container as b on a.load_container_id=b.id and b.id='.$id.' 
						left join orders as d on a.orders_id=d.id')
				->where('a.load_container_id='.$id.' ')
				->group('d.factory_id')
				->select();    
			return $info;
		}
	}
	
	/**
	 * 设置EMAIL发地址信息
	 *
	 * @param  array $info
	 * @param  array $info
	 */
	public function flowEmailDetail($info,$email_address){ 
		$info	= array('email_address'=>$email_address,'post'=>array('comp_id'=>$info['factory_id']));
		return $info;
	}
	
}
?>